<template>
  <div class="nature">
    <div class="natures">
      <div class="natures_box">
        <img style="width: 60px" src="../../../assets/newimg/gys.png" alt="" />
        <div style="margin-left: 10px; flex: 1">
          <div class="natures_zhong">
            <div style="font-weight: 600">
              {{
                signalsRadio1.xiangqing?.title?.replace(/<[^>]+>/g, "") ||
                router.currentRoute.value.query.name.replace(/<[^>]+>/g, "")
              }}
            </div>
          </div>
          <div style="display: flex">
            <span class="activeSpan">公司规模 {{ signalsRadio1.xiangqing.staffNum }}人</span>
            <span class="activeSpan">注册资本
              {{ (signalsRadio1.xiangqing.regCapital ? money(signalsRadio1.xiangqing.regCapital) : '-') }}人民币</span>
            <span class="activeSpan">法定代表人 {{ signalsRadio1.xiangqing.representative }}</span>
          </div>
        </div>
        <div style="display: flex">
          <!-- <span class="shouc">
            <img style="width: 14px; height: 14px; margin-right: 6px" src="@/assets/img/mypoints/xing.png" alt="" />
            收藏
          </span> -->
          <span class="dingyue" @click="subscription">订阅</span>
        </div>
      </div>
      <div>
        <div class="address">
          <div class="address_title">
            <span class="colors">公司地址：</span>
            {{ signalsRadio1.xiangqing.regLocation }}
          </div>
          <div class="address_title">
            <span class="colors">邮箱：</span>
            {{
              signalsRadio1.xiangqing.emailList
                ? signalsRadio1.xiangqing.emailList[0]
                : "-"
            }}
          </div>
        </div>
        <div class="synopsis">
          <!-- <div :class="{ colors: gengduo1s, container: gengduo1s1 }"
            v-if="signalsRadio1.xiangqing.regLocation !== undefined">
            公司简介：<span style="color: #333">{{
                " 注册地 " + signalsRadio1.xiangqing.regLocation +
                " 法定代表人 " +
                signalsRadio1.xiangqing.representative +
                " 公司规模 " +
                signalsRadio1.xiangqing.staffNum +
                "人" +
                " 注册资金 " +
                money(signalsRadio1.xiangqing.regCapital) +
                "人民币"
              }}</span>
          </div> -->
          <!-- <div :class="{ colors: gengduo1s, container: gengduo1s1 }">
            公司简介：
            <span style="color: #333">{{
                " 注册地 " + '&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp' +
                " 法定代表人 " +
                (signalsRadio1.xiangqing.representative ? signalsRadio1.xiangqing.representative :
                  '-&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp')
                +
                " 公司规模 " +
                (signalsRadio1.xiangqing.staffNum ? signalsRadio1.xiangqing.staffNum : '-&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp')
                +
                "人" +
                " 注册资金 " +
                (signalsRadio1.xiangqing.regCapital ? money(signalsRadio1.xiangqing.regCapital) :
                  '-&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp')
                +
                "人民币"
              }}</span>
          </div> -->
          <!-- <el-button size="small" text @click="gengduo1">{{ gengduo1s1 ? "收起" : "更多" }}
            <img src="../../../assets/img/JTX.png" alt="" style="transform: scale(0.5) rotate(180deg);"
              v-if="gengduo1s1">
            <img src="../../../assets/img/JTX.png" alt="" style="transform: scale(0.5) " v-else>
          </el-button> -->
        </div>
        <div class="synopsis">
          <div :class="{ colors: gengduo2s, container: gengduo2s2 }">
            经营范围：<span style="color: #333">{{
              signalsRadio1.xiangqing.businessScope
            }}</span>
          </div>
          <el-button size="small" text @click="gengduo2">{{ gengduo2s2 ? "收起" : "更多" }}
            <img src="../../../assets/img/JTX.png" alt="" style="transform: scale(0.5) rotate(180deg);"
              v-if="gengduo2s2">
            <img src="../../../assets/img/JTX.png" alt="" style="transform: scale(0.5) " v-else>
          </el-button>
        </div>
      </div>
    </div>
    <div style="background-color: #f6f6f6">
      <div class="natures">
        <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
          <el-tab-pane name="1" v-if="zhansId != 7">
            <template #label>
              <span class="custom-tabs-label">
                <span class="xuanz">招标({{ zongshi.zhaobiao }})</span>
                <!-- signalsRadio1.zhaobaioTiTle -->
                <!-- <span>()</span> -->
              </span>
            </template>
            <Tender :parentMethod="parentMethod" v-if="activeName == '1' && zbqx !== 1" :sid="1" />
            <vipsss v-else-if="activeName == '1' && zbqx == 1" />
          </el-tab-pane>
          <el-tab-pane name="4" v-if="zhansId == 7">
            <template #label>
              <span class="custom-tabs-label">
                <span class="xuanz">代理项目({{ signalsRadio1.zhaobaioTiTle }})</span>
                <!-- signalsRadio1.zhaobaioTiTle -->
                <!-- <span>({{ zongshi.zhaobiao }})</span> -->
              </span>
            </template>
            <Tender :parentMethod="parentMethod" v-if="activeName == '4' && dlxmqx !== 1" :sid="4" />
            <vipsss v-else-if="activeName == '4' && dlxmqx == 1" />
          </el-tab-pane>
          <el-tab-pane name="2" v-if="zhansId != 7">
            <template #label>
              <span class="custom-tabs-label">
                <span class="xuanz">中标({{ zongshi.zhongbiao }})</span>
                <!-- signalsRadio1.zhongbaioTiTle -->
                <!-- <span></span> -->
              </span>
            </template>
            <Successful :parentMethod="parentMethod" v-if="activeName == '2' && zhongbqx !== 1" />
            <vipsss v-else-if="activeName == '2' && zhongbqx == 1" />
          </el-tab-pane>
          <el-tab-pane name="3" v-if="zhansId != 7">
            <template #label>
              <span class="custom-tabs-label">
                <span class="xuanz">未中标({{ zongshi.weizhongbiao }})</span>
                <!-- signalsRadio1.weizhongbaioTiTle -->
                <!-- <span></span> -->
              </span>
            </template>
            <Unsuccessful v-if="activeName == '3' && wzbqx !== 1" />
            <vipsss v-else-if="activeName == '3' && wzbqx == 1" />
          </el-tab-pane>
          <el-tab-pane name="10" v-if="zhansId != 7">
            <template #label>
              <span class="custom-tabs-label">
                <span @click="fnijian" style="color: #333" v-if="activeName == '10' && njxmqx !== 1">拟建项目</span>
                <span style="color: #333" v-else>拟建项目</span>
              </span>
            </template>
            <vipsss v-if="activeName == '10' && njxmqx == 1" />
          </el-tab-pane>
          <el-tab-pane name="5">
            <template #label>
              <span class="custom-tabs-label">
                <span class="xuanz">联系人({{
                  Number(signalsRadio1.zhaoblianxiren) +
                  Number(signalsRadio1.zhongbiaolianxiren)
                }})</span>
                <!-- <span></span> -->
              </span>
            </template>
            <assoct v-if="activeName == '5' && lxrqx !== 1" />
            <vipsss v-else-if="activeName == '5' && lxrqx == 1" />
          </el-tab-pane>
          <el-tab-pane name="6" v-if="zhansId != 7">
            <template #label>
              <span class="custom-tabs-label">
                <span @click="ycClick" style="color: #333">招标预测</span>
              </span>
            </template>
            <forecast v-if="activeName == '6' && zbycqx !== 1" />
            <vipsss v-else-if="activeName == '6' && zbycqx == 1" />
          </el-tab-pane>
          <!-- disabled -->
          <el-tab-pane name="7" v-if="zhansId != 7">
            <template #label>
              <span class="custom-tabs-label">
                <span @click="pkClick" style="color: #333">竞争对手分析</span>
                <span></span>
              </span>
            </template>
            <RivalsPk v-if="activeName == '7' && jzdsqx !== 1" />
            <vipsss v-else-if="activeName == '7' && jzdsqx == 1" />
          </el-tab-pane>
          <el-tab-pane name="8" v-if="zhansId != 7">
            <template #label>
              <span class="custom-tabs-label">
                <span @click="tupu" style="color: #333">企业关系图谱</span>
                <span></span>
              </span>
            </template>
            <Enterprise v-if="activeName == '8' && qygxtpqx !== 1" />
            <vipsss v-else-if="activeName == '8' && qygxtpqx !== 1" />
          </el-tab-pane>
          <el-tab-pane name="9">
            <template #label>
              <span class="custom-tabs-label">
                <span @click="fnxi" style="color: #333" v-if="activeName == '9' && qygxtpqx !== 1">企业分析</span>
                <span style="color: #333" v-else>企业分析</span>
              </span>
            </template>

            <vipsss v-if="activeName == '9' && qygxtpqx == 1" />
          </el-tab-pane>
        </el-tabs>
      </div>
    </div>
  </div>
  <Fotter />
  <!-- <Vips /> -->
</template>

<script setup>
import { userInfo } from '@/Api/api.js'
import Tender from "./conperter/tender/index.vue";
import Successful from "./conperter/successful/index.vue";
import Unsuccessful from "./conperter/unsuccessful/index.vue";
import assoct from "./conperter/assoct/index.vue";
import Enterprise from "./conperter/Enterprise/index.vue";
import RivalsPk from "./conperter/rivalsPk/index.vue";
import Fotter from "@/components/fotter/index.vue";
import Vip from "@/components/vip/index.vue";
// import Vips from "@/components/vipts/index.vue";
import vipsss from "./conperter/vipsss/index.vue";
import { ElMessage } from "element-plus";
import { useRouter } from "vue-router";
import { money } from "@/utils/index";

import { useCounterStore } from "@/pain/login/login";
import { useRadio1Store } from "@/pain/search/search";
import { onMounted } from "vue";
import { ref, reactive } from "vue";
import { useCounterVip } from "@/pain/vip/index.js";
import forecast from "./conperter/forecast/index.vue";
import { getab_num, company_read } from "@/Api/shoop/index";
// import { decrypt } from "@/utils/index";
const useVip = useCounterVip();
const usedl = useCounterStore();
const signalsRadio1 = useRadio1Store();
let activeName = ref("1");
let zongshi = ref({});
const router = useRouter();
const zhansId = ref(0)
const zbqx = ref()
const zhongbqx = ref()
const wzbqx = ref()
const njxmqx = ref()
const lxrqx = ref()
const zbycqx = ref()
const jzdsqx = ref()
const qygxtpqx = ref()
const qyqx = ref()
const dlxmqx = ref()
const tokens = localStorage.getItem("token")
const levelId = ref()
let zhaobiao = reactive({
  offerings: "",
  leave: [],
  market: [],
  quarter: [],
  time: [
    {
      oneTime: "",
      twoTime: "",
    },
  ],
  gGoname: "2",
});
let token


if (tokens) {
  userInfo().then(rex => {
    token = rex.data.data
    levelId.value = token.level_id;
    signalsRadio1.level_id = token.level_id;
    company_read().then((res) => {
      if (res.data.data.zb_company.indexOf(levelId.value.toString()) == '-1') {
        zbqx.value = 1
      } else {
        zbqx.value = 0
      }
      if (res.data.data.zbz_company.indexOf(levelId.value.toString()) == '-1') {
        zhongbqx.value = 1
      } else {
        zhongbqx.value = 0
      }
      if (res.data.data.dlxm_company.indexOf(levelId.value.toString()) == '-1') {
        dlxmqx.value = 1
      } else {
        dlxmqx.value = 0
      }
      if (res.data.data.wzb_company.indexOf(levelId.value.toString()) == '-1') {
        wzbqx.value = 1
      } else {
        wzbqx.value = 0
      }
      if (res.data.data.njxm_company.indexOf(levelId.value.toString()) == '-1') {
        njxmqx.value = 1
      } else {
        njxmqx.value = 0
      }
      if (res.data.data.lxr_company.indexOf(levelId.value.toString()) == '-1') {
        lxrqx.value = 1
      } else {
        lxrqx.value = 0
      }
      if (res.data.data.zbyc_company.indexOf(levelId.value.toString()) == '-1') {
        zbycqx.value = 1
      } else {
        zbycqx.value = 0
      }
      if (res.data.data.jzdsfx_company.indexOf(levelId.value.toString()) == '-1') {
        jzdsqx.value = 1
      } else {
        jzdsqx.value = 0
      }
      if (res.data.data.qygxtb_company.indexOf(levelId.value.toString()) == '-1') {
        qygxtpqx.value = 1
      } else {
        qygxtpqx.value = 0
      }
      if (res.data.data.qyfx_company.indexOf(levelId.value.toString()) == '-1') {
        qyqx.value = 1
      } else {
        qyqx.value = 0
      }
    });
  })
} else {
  levelId.value = 0
}
signalsRadio1.company_name = router.currentRoute.value.query.name;
signalsRadio1.lianxi_id = router.currentRoute.value.query.id;

if (router.currentRoute.value.query.id) {
  zhansId.value = router.currentRoute.value.query.id
  if (zhansId.value == 7) {
    activeName.value = '4'
    signalsRadio1.getNewData(router.currentRoute.value.query.name, 1);
    signalsRadio1.lianxi_canshu = zhaobiao;
    signalsRadio1.getcompany_contact();
  }
}

if (router.currentRoute.value.query.tag) {
  let tag = router.currentRoute.value.query.tag
  activeName.value = tag.toString()
  if (tag == 5) {
    signalsRadio1.lianxi_canshu = zhaobiao;
    signalsRadio1.getcompany_contact();
  }
}

signalsRadio1.xiangqing_id = activeName.value;


let gengduo1s = ref(true);
let gengduo1s1 = ref(false);
let gengduo2s = ref(true);
let gengduo2s2 = ref(false);
const gengduo1 = () => {
  gengduo1s.value = !gengduo1s.value;
  gengduo1s1.value = !gengduo1s1.value;
};
const gengduo2 = () => {
  gengduo2s.value = !gengduo2s.value;
  gengduo2s2.value = !gengduo2s2.value;
};
const subscription = () => {
  if (token == null) {
    usedl.uselogin = true;
    return;
  }
  let dat = {
    type_id: router.currentRoute.value.query.id,
    clientid: token.clientid,
    s_condition: ["1"],
    kewords: router.currentRoute.value.query.name,
  };
  signalsRadio1.subscriptionxq(dat);
  if (signalsRadio1.msg != "") {
    ElMessage({
      message: signalsRadio1.msg,
      type: "success",
    });
  }
};

const getab_nums = () => {
  let list = {
    company_name: router.currentRoute.value.query.name,
  };
  getab_num(list).then((res) => {
    let {
      data: { data },
    } = res;
    console.log(data);
    zongshi.value = data;
  });
};





signalsRadio1.getcompany_sums();
signalsRadio1.getcompany_names();
signalsRadio1.getcompany_details();
signalsRadio1.getcompany_detail_lxs();
signalsRadio1.getcompany_detail_zb_lxs();
const handleClick = (tab) => {
  activeName.value = tab.props.name;
  signalsRadio1.xiangqing_id = tab.props.name;
  if (tab.props.name == "1") {
    signalsRadio1.getcompany_details();
  } else if (tab.props.name == "2") {
    signalsRadio1.getcompany_detail_zbs();
  } else if (tab.props.name == "5") {
    signalsRadio1.lianxi_canshu = zhaobiao;
    signalsRadio1.getcompany_contact();
  } else if (tab.props.name == "7") {
    signalsRadio1.getcompetitors();
  } else if (tab.props.name == "3") {
    signalsRadio1.getcompany_detail_wzbs();
  }
};

const tupu = () => {
  if (token == null) {
    usedl.uselogin = true;
    return;
  }
  if (token.level_id < 2) {
    useVip.maskShow = true;
    return;
  }
};

const pkClick = () => {
  if (token == null) {
    usedl.uselogin = true;
    return;
  }
  if (token.level_id < 2) {
    useVip.maskShow = true;
    return;
  }
};
const ycClick = () => {
  if (token == null) {
    usedl.uselogin = true;
    return;
  }
  if (token.level_id < 2) {
    useVip.maskShow = true;
    return;
  }
};

const fnxi = () => {
  if (token == null) {
    usedl.uselogin = true;
    return;
  }
  if (token.level_id < 2) {
    useVip.maskShow = true;
  } else {
    activeName.value = "1";
    const href = router.resolve({
      path: "/companyanalysis",
      query: {
        name:
          router.currentRoute.value.query.name ||
          signalsRadio1.xiangqing?.title,
      },
    });
    window.open(href.href, "_blank");
  }
};

const fnijian = () => {
  if (token == null) {
    usedl.uselogin = true;
    return;
  }
  if (token.level_id < 2) {
    useVip.maskShow = true;
  } else {
    const href = router.resolve({
      path: "/search",
      query: {
        name:
          router.currentRoute.value.query.name ||
          signalsRadio1.xiangqing?.title,
        id: "6",
      },
    });
    window.open(href.href, "_blank");
  }
};

const parentMethod = () => {
  activeName.value = "5";
  signalsRadio1.lianxi_canshu = zhaobiao;
  signalsRadio1.getcompany_contact();
};

onMounted(() => {
  getab_nums();
  // router.currentRoute.value.query.id
});
</script>

<style lang="scss" scoped>
.el-tabs__active-bar {
  height: 1px;
}

::v-deep .el-tabs__nav-wrap::after {
  height: 1px;
  color: #dddddd;
}

.custom-tabs-label {
  // color: #abb3c3;
  font-size: 16px;
}

::v-deep .el-tabs__item.is-active {
  color: red !important;
}

::v-deep .el-tabs__active-bar {
  background-color: red;
  height: 2px;
}

.el-tabs__item .is-active :hover {
  background-color: red !important;
}

.natures {
  margin-top: 10px;
  padding: 10px 20px 0 20px;
  border-radius: 4px;
  background-color: #fff;
}

.activeSpan {
  height: 20px;
  padding: 0 6px;
  margin-top: 10px;
  margin-right: 10px;
  border-radius: 4px;
  line-height: 20px;
  font-family: Source Han Sans CN;
  font-size: 12px;
  background: #fce2e0;
  color: #f43107;
}

.gengduo {
  color: #f43107;
}

// .containerNo {
//     width: 1020px !important;
//     overflow: hidden;
//     text-overflow: ellipsis;
// }

.container {
  width: 1095px;
  // white-space: nowrap;
  line-height: 25px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #a9b1be;
}

.colors {
  width: 1095px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
  color: #a9b1be;
}

.nature {
  width: 1200px;
  margin: 0 auto;

  .natures_box {
    display: flex;
    justify-content: space-between;

    .natures_zhong {
      height: 20px;
      align-items: center;
    }

    .shouc {
      display: flex;
      justify-content: center;
      align-items: center;
      height: 36px;
      width: 80px;
      margin-right: 10px;
      background-color: #ff4848;
      border-radius: 4px;
      font-size: 14px;
      color: #ffffff;
    }

    .dingyue {
      display: flex;
      justify-content: center;
      align-items: center;
      height: 36px;
      width: 80px;
      background-color: #ffb430;
      border-radius: 4px;
      font-size: 14px;
      color: #ffffff;
      cursor: pointer;
    }
  }
}

.address {
  display: flex;
  justify-content: space-between;
  width: 560px;
  margin-top: 10px;

  .address_title {
    width: 344px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
  }
}

.synopsis {
  display: flex;
  align-items: center;
  margin-top: 5px;
  font-size: 14px;
}

.el-button {
  color: #f43107;
}

.el-tabs__item :hover {
  background-color: red !important;
}

:deep() {

  .el-tabs__item :hover {
    // padding: 0 10px;
    color: red !important;
    // box-sizing: border-box;
  }

}

.dev :hover {
  color: #fce2e0 !important;
}

.xuanz {
  color: #333;
}

.is-active .xuanz {
  color: red
}
</style>
